#pragma once

#include <iostream>
#include <string>
#include <memory>
#include "Socket.hpp"

using namespace socket_ns;

class SelectServer
{
    const static int N = sizeof(fd_set)*8;
    const static int defaultfd  = -1;

public:
    SelectServer(uint16_t port)
    :_port(port),
     _listensock(std::make_unique<TcpSocket>())
    {
        InetAddr addr("0",_port);
        _listensock->BuildListenSocket(addr);
        for(int i = 0; i< N;i++)
        {
            _fd_array[i] = defaultfd;
        }
    }

private:
    uint16_t _port;
    std::unique_ptr<Socket> _listensock;
    int _fd_array[N];
};